#lang racket

;TAGGED-DATA--------------------------------------------------------------------------------------------------

(define (attach-tag type-tag contents)
  (cond ((number? contents) contents)
        (else (cons type-tag contents))))

(define (type-tag datum)
  (cond ((number? datum) 'scheme-number) 
        ((pair? datum) (car datum))
        (else (error "Incorrect tagged data: " datum))))

(define (contents datum)
  (cond ((number? datum) datum) 
        ((pair? datum) (cdr datum))
        (error "Incorrect tagged data: " datum)))


;TEST---------------------------------------------------------------------------------------------
(attach-tag 'tag '(datum))
(attach-tag 'tag 10)
(type-tag '(tag contents))
(type-tag 10)
(contents '(tag contents))
(contents 10)